//
//  UserInfo.m
//  ElectronicMall
//
//  Created by 史伟文 on 15/1/18.
//  Copyright (c) 2015年 cczu. All rights reserved.
//

#import "UserInfo.h"

@implementation UserInfo

static UserInfo *userinfo;

+ (UserInfo *)sharedUserInfo
{
    if (userinfo == nil) {
        userinfo = [[UserInfo alloc] init];
    }
    return userinfo;
}

- (id)init
{
    if (self = [super init]) {
        _m_isLogin = [[NSUserDefaults standardUserDefaults] boolForKey:@"m_isLogin"];
        _m_session = [[NSUserDefaults standardUserDefaults] objectForKey:@"m_session"];
        _m_userName = [[NSUserDefaults standardUserDefaults] objectForKey:@"m_userName"];
        _m_nickName = [[NSUserDefaults standardUserDefaults] objectForKey:@"m_nickName"];
    }
    return self;
}

- (void)saveUserInfo
{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setBool:_m_isLogin forKey:@"m_isLogin"];
    [defaults setObject:_m_session forKey:@"m_session"];
    [defaults setObject:_m_userName forKey:@"m_userName"];
    [defaults setObject:_m_nickName forKey:@"m_nickName"];
    [defaults synchronize];
}

- (void)removeUserInfo
{
    NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults];
    [defaults removeObjectForKey:@"m_isLogin"];
    [defaults removeObjectForKey:@"m_session"];
    [defaults removeObjectForKey:@"m_userName"];
    [defaults removeObjectForKey:@"m_nickName"];
    [defaults synchronize];
}

@end
